package com.ruirenyun.controller;

import com.ruirenyun.entity.AdPosition;
import com.ruirenyun.service.AdPositionService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 广告位管理表(AdPosition)表控制层
 *
 * @author makejava
 * @since 2021-04-20 11:47:10
 */
@RestController
@RequestMapping("adPosition")
public class AdPositionController {
    /**
     * 服务对象
     */
    @Resource
    private AdPositionService adPositionService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("getById")
    public AdPosition getById(Long id) {
        return this.adPositionService.getById(id);
    }

    /**
     * 通过对象查询筛选记录
     * @param adPosition
     * @return
     */
    @GetMapping("getList")
    public List<AdPosition> getList(AdPosition adPosition) {
        adPosition.setAdName("首页焦点图");
        return this.adPositionService.getList(adPosition);
    }

    @PostMapping("insertAdPosition")
    public AdPosition insertAdPosition(AdPosition adPosition) {
        adPosition.setBelongSys(0);
        adPosition.setAdName("测试");
        adPosition.setAdType("图片");
        adPosition.setAdSize("750*338");
        adPosition.setMaxNum(2);
        adPosition.setStatus(1);
        adPosition.setSwitchingPeriod(2);
        return this.adPositionService.insertSelective(adPosition);
    }
    /**
     * 测试git分支代码合并
     */

}
